package com.example.androidstart.homepage.viewholder;

import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.example.androidstart.R;
import com.example.androidstart.homepage.CustomViewHolder;

import com.example.androidstart.homepage.IViewHolderCreator;
import com.example.androidstart.homepage.bean.IconInfoBean;
import com.example.androidstart.homepage.item.IconItemInfo;

public class IconViewHolder extends CustomViewHolder<IconItemInfo> {
    private IconViewHolder(@NonNull View itemView) {
        super(itemView);
    }

    public static final IViewHolderCreator<IconViewHolder> CREATOR = new IViewHolderCreator<IconViewHolder>() {
        @Override
        public IconViewHolder createViewHolder(View itemView) {
            return new IconViewHolder(itemView);
        }

        @Override
        public int getLayoutId() {
            return R.layout.homepage_icon_layout;
        }
    };

    @Override
    public void initView() {
        super.initView();

    }

    @Override
    public void onBind(IconItemInfo iconItemInfo) {
        super.onBind(iconItemInfo);
        IconInfoBean iconInfoBean = iconItemInfo.getItemInfo();
        TextView iconA = itemView.findViewById(R.id.A);
        iconA.setBackground(itemView.getContext().getDrawable(iconInfoBean.getmIconImgRes()));
        TextView iconB = itemView.findViewById(R.id.B);
        iconB.setBackground(itemView.getContext().getDrawable(iconInfoBean.getmIconImgRes()));
        TextView iconC = itemView.findViewById(R.id.C);
        iconC.setBackground(itemView.getContext().getDrawable(iconInfoBean.getmIconImgRes()));
    }
}
